<style lang="less">
	@import "./login.less";
</style>

<template>
	<div class="login">
		<div class="login-con">
			<Card icon="log-in" title="欢迎登录" :bordered="false">
				<div class="form-con clear">
					<login-form @on-success-valid="handleSubmit" ref='form'></login-form>
					<!-- <a @click="getForget" class="fr">忘记密码？</a> -->
				</div>
			</Card>
		</div>
	</div>
</template>

<script>
	import LoginForm from '_c/login-form'
	// import { mapActions } from 'vuex'
	export default {
		components: {
			LoginForm
		},
		methods: {
			// getForget () {
			//   this.$router.push({
			//     name: 'Forget'
			//   })
			// },
			handleSubmit() {
				let params = this.qs.stringify({
					username: this.$refs.form.form.yunyName,
					password: this.$refs.form.form.password,
					validateType: 'admin.' + this.$refs.form.form.yunyName,
					unifiedCode: this.$refs.form.form.code
				})

				this.axios.post('admin/index/signUp', params, {
						headers: {
							Authorization: 'Basic bWMtYmFjazpkb2RvdS1tYw==',
							deviceId: localStorage.k1
						}
					})
					.then(res => {
						// console.log(this.$refs.form.form.yunyName+','+this.$refs.form.form.password+','+this.$refs.form.form.code)
						if(res.data.code == 200) {
							//  请求头信息保存在localStorage
							localStorage.setItem('mytoken', res.data.data.token.access_token)
							localStorage.meus = res.data.data.menus
							this.$Message.info(res.data.msg)
							this.$router.push({
								name: 'home'
							})
						}
					})
			}
		},
		mounted() {
			this.$Message.config({
				top: 250
			})
			localStorage.removeItem('mytoken')
		}
	}
</script>

<style>

</style>